package cn.ersan.boot.sms.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sns.SnsClient;

/**
 * @author 86189
 */
@Configuration
public class SNSConfig {

    @Bean
    public SnsClient snsClient(AwsMessageConfig config) {
        AwsBasicCredentials awsCredentials = AwsBasicCredentials.create(config.getAwsAccessKeyId(), config.getAwsSecretAccessKey());

        return SnsClient.builder()
                .region(Region.of(config.getAwsRegion()))
                .credentialsProvider(StaticCredentialsProvider.create(awsCredentials))
                .build();
    }
}
